package com.cskaoyan.controller.lz_controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.lzpackage.lz_wx.WxData;
import com.cskaoyan.mapper.ElseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/config")
public class AdminWxController {
    @Autowired
    ElseMapper elseMapper;
    @GetMapping("wx")
    public BaseRespVo list() {
        String goods= elseMapper.selectWx("market_wx_catlog_goods");
        String list= elseMapper.selectWx("market_wx_catlog_list");
        String brand= elseMapper.selectWx("market_wx_index_brand");
        String hot= elseMapper.selectWx("market_wx_index_hot");
        String index_new= elseMapper.selectWx("market_wx_index_new");
        String topic= elseMapper.selectWx("market_wx_index_topic");
        String share= elseMapper.selectWx("market_wx_share");

        WxData wxData=new WxData();
        wxData.setMarket_wx_catlog_goods(goods);
        wxData.setMarket_wx_catlog_list(list);
        wxData.setMarket_wx_index_brand(brand);
        wxData.setMarket_wx_index_hot(hot);
        wxData.setMarket_wx_index_new(index_new);
        wxData.setMarket_wx_index_topic(topic);
        wxData.setMarket_wx_share(share);
        return BaseRespVo.ok(wxData);
    }
    @PostMapping("wx")
    public BaseRespVo list1(@RequestBody WxData wxData) {
        elseMapper.updateWx("market_wx_catlog_goods",wxData.getMarket_wx_catlog_goods());
        elseMapper.updateWx("market_wx_catlog_list",wxData.getMarket_wx_catlog_list());
        elseMapper.updateWx("market_wx_index_brand",wxData.getMarket_wx_index_brand());
        elseMapper.updateWx("market_wx_index_hot",wxData.getMarket_wx_index_hot());
        elseMapper.updateWx("market_wx_index_new",wxData.getMarket_wx_index_new());
        elseMapper.updateWx("market_wx_index_topic",wxData.getMarket_wx_index_topic());
        elseMapper.updateWx("market_wx_share",wxData.getMarket_wx_share());
        return BaseRespVo.out();
    }
}
